'use strict';

angular.module('com.dcos.app').controller('EnvironmentController', function($window,$state, $scope,$filter, api, $uibModal,EnvironmentService,dialog) {
  var vm = this;
  vm.breadCrumbArr = [api.breadCrumbMap.environment.root];
  vm.initPageSize = api.initPageSize;

  vm.userid=$window.sessionStorage.getItem("curUserId");

  // if(!vm.userid)
  //   $state.go('login');

  vm.msg="删除操作不可恢复，确定要删除？";

  vm.curProjectId=$window.sessionStorage.getItem("curProjectId");

  vm.environData=[];

  vm.getEnvironList = function() {

    EnvironmentService.getlist(vm.curProjectId).then(function (response) {
        vm.environData=response.data.data;
    });
  }
  vm.getEnvironList();

  vm.fnedit = function (e_id,c_id) {
    var modalInstance = $uibModal.open({
      animation: true,
      templateUrl: 'controllers/environment/detail/detail.html',
      controller: 'EnvironmentDetailController as vm',
      resolve: {
        e_id:function(){return e_id;},
        c_id:function(){return c_id;},
        reload:function(){return vm.getEnvironList;}
      }
    });
  }
  $scope.ok = function(environ_id) {
    EnvironmentService.delete(environ_id).then(function (response) {
      vm.getEnvironList();
    });
  }

});

